package com.colorlight.cloud.complete.entity.po;

import com.colorlight.cloud.complete.entity.enumerate.FanIndex;
import com.colorlight.cloud.complete.entity.enumerate.FanState;
import com.colorlight.cloud.gateway.api.message.constraint.basics.object.Trans;
import com.colorlight.iot.proto.complete.entity.CompleteEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FanInfo implements Trans<FanInfo, CompleteEntity.FanInfo> {

    /**
     * 序号
     */
    private FanIndex index;

    /**
     * 风扇状态是否正常
     */
    private FanState fansState;

    /**
     * 风扇是否开启
     */
    private Boolean fanOpen;

    /**
     * 风扇转速，转/分钟
     */
    private Integer fanSpeed;

    @Override
    public FanInfo formProto(CompleteEntity.FanInfo fanInfo) {
        FanInfo fanInfo1 = Trans.super.formProto(fanInfo);
        // proto框架问题，如果枚举是0的情况下，会丢失
        if(fanInfo1.getIndex() == null){
            fanInfo1.setIndex(FanIndex.FAN_INDEX_1);
        }
        return fanInfo1;
    }
}

